package com.lixl.threadpool;

import java.util.concurrent.ArrayBlockingQueue;

public class A {
	
	private static ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<String>(25);
	
	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			queue.add(""+i);
		}
		
		
		while(true){
			System.out.println(queue.size());
			Person p = new A.Person();
			p.start();
			if(p.isAlive() && queue.size()>1){
				continue;
			}else {
				break;
			}
		}
	}
	
	private static ArrayBlockingQueue<Runnable> worker = new ArrayBlockingQueue<Runnable>(5);
	public static void execute(Runnable r){
		worker.add(r);
	}
	
	static class Person extends Thread{
		
		@Override
		public void run() {
			try {
				System.out.println(this.getName()+" peek "+ queue.take());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
	}
	
}
